<?php

namespace pay\modules\backend\models;

use Yii;

/**
 * This is the model class for table "pay_reward_config".
 *
 * @property int $hid
 * @property int $app_id
 * @property int $pay_ser_id
 * @property string $total_amount
 * @property string $min_amount
 * @property string $max_amount
 * @property int $win_rate
 * @property string $start_time
 * @property string $end_time
 * @property string $create_time
 */
class RewardConfig extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'pay_reward_config';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['app_id', 'pay_ser_id', 'total_amount', 'min_amount', 'max_amount'], 'required'],
            [['app_id', 'pay_ser_id', 'win_rate'], 'integer'],
            [['total_amount', 'min_amount', 'max_amount'], 'number'],
            [['start_time', 'end_time', 'create_time'], 'safe'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'hid' => 'Hid',
            'app_id' => 'App ID',
            'pay_ser_id' => 'Pay Ser ID',
            'total_amount' => 'Total Amount',
            'min_amount' => 'Min Amount',
            'max_amount' => 'Max Amount',
            'win_rate' => 'Win Rate',
            'start_time' => 'Start Time',
            'end_time' => 'End Time',
            'create_time' => 'Create Time',
        ];
    }


    /*** 获取
     * @param $app_id
     * @return array|null|\yii\db\ActiveRecord
     */
    public function getConfigInfo($app_id,$hid = '')
    {
        $data = self::find()->where('app_id = :aid',[':aid' => $app_id])->asArray()->one();
        return $data;
    }
    
    
    
}
